package com.sgb.contract.view.ui.details;

import android.text.TextUtils;
import android.view.View;

import androidx.core.content.ContextCompat;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.sgb.contract.R;
import com.sgb.contract.model.ApprovalLogBean;

import java.util.List;


/**
 * 描述:合同-审批日志适配器
 *
 * @author qiangHeNoo
 * <p>
 * 时间:2021.11.03
 */
public class ApprovalLogAdapter extends BaseQuickAdapter<ApprovalLogBean, BaseViewHolder> {

    public ApprovalLogAdapter(List<ApprovalLogBean> bean) {
        super(R.layout.contract_approval_log_adapter, bean);
    }

    @Override
    protected void convert(BaseViewHolder helper, final ApprovalLogBean item) {
        if (getData().size() == 0) {
            return;
        }
        helper
                .setText(R.id.contract_type, item.optType == -1 ? "发起流程" : item.optType == 0 ? "已拒绝" : item.optType == 1 ? "已通过" : "审批中")
                .setText(R.id.contract_log_time, item.time)
                .setText(R.id.contract_log_content, TextUtils.isEmpty(item.reason) ? "/" : item.reason)
                .setText(R.id.contract_creator_name, item.optUserName)
                .setTextColor(R.id.contract_type, ContextCompat.getColor(mContext, item.optType == -1 ? R.color.contract_color_B79255 : item.optType == 0 ? R.color.contract_color_EF4033 :
                        item.optType == 1 ? R.color.contract_color_06C764 : R.color.color_5792FD));
        helper.getView(R.id.contract_view1).setVisibility(helper.getLayoutPosition() == 0 ? View.INVISIBLE : View.VISIBLE);
        helper.getView(R.id.contract_view2).setVisibility(helper.getLayoutPosition() == getData().size() - 1 ? View.INVISIBLE : View.VISIBLE);
    }
}
